﻿/*****************************************************************************
 
 Use of Ext is under the Ext JS license, for more information, 
 please visit http://extjs.com/products/license.php page. 
  
 You should confirm that you have read, understood and accept ethical criteria listed. 
 If not, see <http://www.mvcnext.com/license/>.
  
 Version: 1.0.0.0
 Website: http://www.mvcnext.com/
 
 For continued development and updates, visit http://yogsbreath.net
 
 ******************************************************************************/
using System;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Web.UI;
using System.Reflection;

namespace MVCnExt.Web.UI.Ext
{
    public class ExtColorPalette : ExtComponent
    {
        public override IList<ScriptDescriptor> GetScriptDescriptors()
        {
            IList<ScriptDescriptor> list = base.GetScriptDescriptors();

            ScriptControlDescriptorBase desc = (ScriptControlDescriptorBase)list[0];

            desc.Type = "Ext.ColorPalette";

            String[] properties = new String[]{
                "allowReselect", "itemCls", "tpl", "value", "colors"
            };

            Type component = typeof(ExtDatePicker);

            foreach (String property in properties)
            {
                PropertyInfo i = component.GetProperty(property);

                if (i == null)
                    throw new InvalidOperationException(String.Format("Property not found, 'Ext.ColorPalette.{0}'", property));

                Object value = i.GetValue(this, null);

                if (value == null)
                    continue;

                if (!(value is String))
                    desc.AddPropertyBase(property, value);
                else
                    desc.AddPropertyBase(property, String.Format("'{0}'", value));
            }

            return list;
        }


        #region Public Properties

        public Boolean? allowReselect { get; set; }

        public String itemCls { get; set; }

        public String tpl { get; set; }

        public String value { get; set; }

        public String colors { get; set; }

        #endregion

    }
}
